/*
 * @Author: your name
 * @Date: 2021-03-30 10:18:07
 * @LastEditTime: 2021-04-10 23:52:04
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \element实战\element_ui\src\main.js
 */
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import MessageBox from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
//导入全局样式表
import './assets/css/global.css'
//导入axios的包对全局的请求进行配置
import axios from "axios"

//导入element Meassage 

import {
  Message
} from "element-ui"

//使用把message挂载到vue的原型链上去
Vue.prototype.$message = Message;
//使用把MessageBos挂载到vue的原型链上去
Vue.prototype.$confirm = MessageBox.confirm
//配置请求的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//axios请求拦截(预处理过程)
//调用interceptors属性，属性中有request调用use回调函数
//为请求头对象，添加Token 验证的Authorization字段
axios.interceptors.request.use(config => {
  console.log(config);
  config.headers.Authorization = window.sessionStorage.getItem('token');
  //在最后必须return config
  return config
})


Vue.prototype.$http = axios
//这样每一个vue的组件都可以通过
//this直接访问到$http从而发起Ajax请求

Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')